package org.apache.dubbo.monitor;

import org.apache.dubbo.rpc.model.ScopeModel;
import org.apache.dubbo.rpc.model.ScopeModelUtil;

public class MonitorFactory$Adaptive implements MonitorFactory {
    public Monitor getMonitor(org.apache.dubbo.common.URL url) {

        String extName = (url.getProtocol() == null ? "dubbo" : url.getProtocol());
        if (extName == null)
            throw new IllegalStateException("Failed to get extension (org.apache.dubbo.monitor.MonitorFactory) name from url (" + url.toString() + ") use keys([protocol])");

        ScopeModel scopeModel = ScopeModelUtil.getOrDefault(url.getScopeModel(), MonitorFactory.class);

        MonitorFactory extension = (MonitorFactory)
                scopeModel.getExtensionLoader(MonitorFactory.class).getExtension(extName);

        return extension.getMonitor(url);
    }
}
